package com.ad.pet.common.data.http.utils;


import com.ad.pet.App;
import com.ad.pet.R;
import com.ad.pet.common.data.utils.ui.ResourcesUtil;

/**
 * Created by ems on 2017/3/3.
 * http响应码统一处理
 */

public class HttpCodeUtil {

    private static ResourcesUtil mResourcesUtil = new ResourcesUtil(App.getApp().getApplicationContext());

    private HttpCodeUtil() {
        //no  instance
    }

    /**
     * 根据code 分析具体是什么错误
     *
     * @param code
     * @return
     */
    public static String byCodeShowErrorMsg(int code) {
        switch (code) {
            case 403:
                return mResourcesUtil.getString(R.string.http_error403_msg);
            case 404:
                return mResourcesUtil.getString(R.string.http_error404_msg);
            case 500:
                return mResourcesUtil.getString(R.string.http_error500_msg);
            default:
                return mResourcesUtil.getString(R.string.http_error_msg);
        }
    }

}
